package cn.com.gensoft.app.core.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.ToString;

import java.io.Serializable;
import java.time.Instant;

/**
 * 实体类基类
 * @author hlj
 */
@ToString
public class BaseEntity <T> implements Serializable {
    /**
     * 创建人
     */
    @TableField(fill = FieldFill.INSERT)
    private String createdBy;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Instant createdDate;
    /**
     * 修改人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String lastModifiedBy;
    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Instant lastModifiedDate;


    public T setCreatedBy(String val) {
        this.createdBy = val;
        return (T) this;
    }

    public T setCreatedDate(Instant val) {
        this.createdDate = val;
        return (T) this;
    }

    public T setLastModifiedBy(String val) {
        this.lastModifiedBy = val;
        return (T) this;
    }

    public T setLastModifiedDate(Instant val) {
        this.lastModifiedDate = val;
        return (T) this;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public Instant getLastModifiedDate() {
        return lastModifiedDate;
    }
}
